<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>注册新用户</title>
    <link rel="stylesheet" href="css/style.css">
    <script src="js/jquery.min.js"></script>
    <script src="js/requestUrl.js"></script>
</head>

<body style="padding-bottom: 0 !important;">
    <div class="login">
        <div class="login_box">
            <div class="logo">
                <img src="img/u257.png" alt="">
            </div>
            <div class="con">
                <div class="tab_content">
                    <ul>
                        <li class="tabs" style="display: block;">
                            <div class="input">
                                <dl>
                                    <input type="text" class="phone input" value="" placeholder="请输入手机号码"
                                        maxlength="11">
                                </dl>
                                <dl>
                                    <input type="text" class="duanxin input" value="" placeholder="请输入短信验证码">
                                    <span class="get_code">发送验证码</span>
                                </dl>
                                <div class="Agreement">
                                    <input id="Agree" name="Agree" type="checkbox">
                                    <label for="Agree">勾选同意<a href="user_agreement.html"
                                            target="_blank">《用户服务协议》</a></label>
                                </div>
                                <div class="login_btn">注册</div>
                                <div class="bottom bot">
                                    <a href="login.html">已有账号，立即登录</a>
                                </div>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="clear"></div>
        <div class="mask" style="z-index: 99">
            <div class="popup">
                <div class="icon">
                    <img src="img/success.png" alt="">
                </div>
                <h1>恭喜您注册成功</h1>
                <ul>
                    <li style="margin: 0 auto;">
                        <a href="http://newtest.sdfa.org.cn/footballAssociation/zuxie/login.html">返回登录</a>
                    </li>
                </ul>
            </div>
        </div>

        <div id="mask">
            <div class="popup">
                <h1>请选择身份</h1>
                <dl style="border:none;margin-top: 30px;height: 30px;line-height: 30px;">
                    <label class="choose" style="margin-right: 10px"><input type="radio" class="group_btn"
                            name="personalOrGroup" value="1">个人</label>
                    <label class="choose" style="margin-left: 10px;"><input type="radio" class="group_btn"
                            name="personalOrGroup" value="2">团体</label>
                </dl>
                <dl class="group_choose" style="line-height: 30px;margin-top: 20px;">
                    <!--                <label class="choose" style="margin-right: 10px;width: auto"><input type="radio" name="groupType"-->
                    <!--                                                                                    value="1">体育运营公司</label>-->
                    <label class="choose" style="margin-right: 10px;width: auto"><input type="radio" name="groupType"
                            value="2" data-zuxieType="">俱乐部</label>
                    <label class="choose" style="margin-right: 10px;width: auto"><input type="radio" name="groupType"
                            value="3" data-zuxieType="">公司</label>
                    <label class="choose" style="margin-right: 10px;width: auto"><input type="radio" name="groupType"
                            value="4" data-zuxieType="">学校</label>
                    <label class="choose" style="width: auto"><input type="radio" name="groupType" value="6"
                            data-zuxieType="1">市级足协</label>
                    <label class="choose" style="width: auto"><input type="radio" name="groupType" value="6"
                            data-zuxieType="2">区级足协</label>
                    <label class="choose" style="width: auto"><input type="radio" name="groupType" value="5"
                            data-zuxieType="">其他</label>
                </dl>
                <ul style="margin-top: 10%;">
                    <li>
                        <a href="javascript:" class="define">确定</a>
                    </li>
                    <li>
                        <a href="javascript:;" class="cancel">取消</a>
                    </li>
                </ul>
            </div>
        </div>
        <div class="clear"></div>
        <div id="viewDiv"></div>
    </div>
    <script src="js/layer/layer.js"></script>
    <script>
        // $('#viewDiv').load('alert.html');
        var html = $('html').css("height")
        $('body').css("height", html)

        //点击获取验证码 + 短信倒计时
        function countDown() {
            let text = 60;
            $('.get_code').html(text);
            let timer = setInterval(function () {
                if (text == 1) {
                    clearInterval(timer);
                    flag = true;
                    $('.get_code').html('发送验证码');
                } else {
                    text -= 1;
                    flag = false;
                    $('.get_code').html(text);
                }
            }, 1000)
        }

        var flag = true;
        $('.get_code').click(function () {
            if (!flag) return false;
            var phone = $(".phone").val();
            if ($(".phone").val().length < 11) {
                layer.alert('请输入手机号', {
                    title: '提示'
                })
                return false;
            }
            // countDown();
            myAjax('/user/sendSms', {
                    phone: phone
                },
                function (data) {
                    if (data.msg == "0") {
                        layer.alert('发送成功', {
                            title: '提示'
                        })
                        countDown();
                    }
                },
                function (err) {
                    console.log(err)
                })
        });
        // 点击注册
        var userId;
        var tel;
        var message;
        var xieyi;
        $('.login_btn').click(function () {
            tel = $(".phone").val();
            message = $(".duanxin").val();
            if (tel == '') {
                layer.alert('请输入手机号码', {
                    title: '提示'
                })
                return
            }
            if (message == '') {
                layer.alert('请输入短信验证码', {
                    title: '提示'
                })
                return
            }
            xieyi = document.getElementById("Agree").checked
            if (xieyi) {

            } else {
                layer.alert('请勾选用户服务协议', {
                    title: '提示'
                })
                return
            }
            $('#mask').fadeIn();
            $('#mask .popup').css('height', 'auto')
        });
        var single;
        $(".group_btn").click(function () {
            single = $("input[name='personalOrGroup']:checked").val();
            if (single == 1) {
                $('.group_choose').hide()
                $('#mask .popup').css('height', 'auto')
            } else if (single == 2) {
                $('.group_choose').show()
                $('#mask .popup').css('height', '340px')
            }
        })
        // 选择身份弹窗点击事件
        $('.define').click(function () {
            var group_type = $("input[name='groupType']:checked").val();
            var zuxieType = $("input[name='groupType']:checked").attr("data-zuxieType");

            if (single == undefined) {
                layer.msg("请选择身份")
                return false
            }
            if (single == "2" && group_type == undefined) {
                layer.msg("请选择身份")
                return false
            }
            $('#mask').fadeOut(300);
            myAjax('/user/register', {
                    tel: tel,
                    smsCode: message,
                    personalOrGroup: single,
                    groupType: group_type,
                    zuxieType: zuxieType
                },
                function (data) {
                    console.log(data)
                    userId = data.userId
                    if (data.msg == 0) {
                        sessionStorage.history = "2";
                        $('.mask').fadeIn(300);
                    } else {
                        layer.alert(data.msg, {
                            title: '提示'
                        })
                    }
                },
                function (err) {
                    console.log(err)
                })
        })
        $('.cancel').click(function () {
            $('#mask').fadeOut();
        })
    </script>
</body>

</html>